package com.site.tasks;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by shengquan.wu on 2018/6/6.
 */
@Component
public class DemoTask {
    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    //定义每3秒执行任务
    @Scheduled(fixedRate = 3000)
    public void reportCurrentTime(){
        System.out.println(dateFormat.format(new Date()));
    }

}
